using System;
using System.Collections.Generic;
using System.Text;
using SerialisationProject;

namespace Community.SharePoint.Tools.SPLookupLinker.Helper
{
    public static class BatchProcessor
    {
        #region SaveObject - Not used
        //public static bool SaveObject(Batch batch)
        //{
        //    bool success = false;
        //    try
        //    {
        //        string xml = batch.Serialize();
        //        FileHelper.Write(@"Sample.XML", xml);
        //        success = true;
        //    }
        //    catch (Exception ex)
        //    {
        //        //Do error handling
        //        success = false;
        //    }
        //    return success;
        //}
        
        #endregion
        public static Batch ReadToObject(string filePath)
        {
            Batch batch = new Batch();

            try
            {
                string xml = FileHelper.Read(filePath);
                batch = Batch.Deserialize(xml) as Batch;
            }
            catch (Exception ex)
            {
                throw new Exception("Error reading Xml file. Details: " + ex.Message, ex);
            }
            return batch;
        }
    }
}
